package com.iknow.util;

import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.SystemClock;
import android.provider.Settings.System;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.widget.DigitalClock;
import java.util.Calendar;

public class DigitalClock extends android.widget.DigitalClock
{
  private static final String m12 = "h:mm";
  private static final String m24 = "k:mm";
  Calendar mCalendar;
  String mFormat;
  private FormatChangeObserver mFormatChangeObserver;
  private Handler mHandler;
  private Runnable mTicker;
  private boolean mTickerStopped = false;

  public DigitalClock(Context paramContext)
  {
    super(paramContext);
    initClock(paramContext);
  }

  public DigitalClock(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    initClock(paramContext);
  }

  private boolean get24HourMode()
  {
    return DateFormat.is24HourFormat(getContext());
  }

  private void initClock(Context paramContext)
  {
    paramContext.getResources();
    if (this.mCalendar == null)
      this.mCalendar = Calendar.getInstance();
    this.mFormatChangeObserver = new FormatChangeObserver(this);
    getContext().getContentResolver().registerContentObserver(Settings.System.CONTENT_URI, true, this.mFormatChangeObserver);
    setFormat();
  }

  private void setFormat()
  {
    if (get24HourMode())
      this.mFormat = "k:mm";
    while (true)
    {
      return;
      this.mFormat = "h:mm";
    }
  }

  protected void onAttachedToWindow()
  {
    this.mTickerStopped = false;
    super.onAttachedToWindow();
    this.mHandler = new Handler();
    this.mTicker = new Runnable(this)
    {
      public void run()
      {
        if (DigitalClock.access$1(this.this$0));
        while (true)
        {
          return;
          this.this$0.mCalendar.setTimeInMillis(System.currentTimeMillis());
          this.this$0.setText(DateFormat.format("k:mm", this.this$0.mCalendar));
          this.this$0.invalidate();
          long l1 = SystemClock.uptimeMillis();
          long l2 = l1 + 1000L - l1 % 1000L;
          DigitalClock.access$2(this.this$0).postAtTime(DigitalClock.access$3(this.this$0), l2);
        }
      }
    };
    this.mTicker.run();
  }

  protected void onDetachedFromWindow()
  {
    super.onDetachedFromWindow();
    this.mTickerStopped = true;
  }

  private class FormatChangeObserver extends ContentObserver
  {
    public FormatChangeObserver()
    {
      super(new Handler());
    }

    public void onChange()
    {
      DigitalClock.access$0(this.this$0);
    }
  }
}